#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.maple import *

# variáveis úteis
half = M('1/2')
t = M.t
_i, _j, _k = M('_i, _j, _k')
rr = M('`..`')
diff = M.diff

# parâmetros iniciais
a = 2 * M(oneof(1, 2, 3, 4))
Nf = oneof(One / 4, Half, One, 3 * Half)
s = oneof(2, 4) * oneof(-1, 1)

# raios
raT = r * t
rbT = s * t

# potencial
U = x * y + a * y ** 2 / 2
Uerr1 = x * y
Uerr2 = y ** 2 / 2
F = diff(U, x) * _i + diff(U, y) * _j
print('a: %s, r,s: %s\nF: %s' % (a, (r, s), F))

# pontos
P = (x == r * M.Pi / 8, y == s * M.Pi / 8)
Pe = (x == r * M.Pi / 4, y == s * M.Pi / 4)

# respostas
work = M.subs(P, U)
distract1 = M.subs(Pe, U)
distract2 = M.subs(P, Uerr1)
distract3 = M.subs(P, Uerr2)
print('work: %s\ndistractors: %s, %s, %s' % (work, distract1, distract2, distract3))
